home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-02-23 | 3.8 KB | 115 lines | [TEXT/GEOL] |
- Item forwarded by A33 to A34
-
- Item 3266425 17-Feb-90 03:04PST
-
- From: D5295 Reseach SW Design, D Goldman,PRT
-
- To: MACAPP.TECH$ MacApp Technical
-
- Sub: Re: Persistent Objects
-
- Just to see if I'm following this all correctly, could somebody tell me whether
- the following would take care of the "Which fields get displayed by the
- debugger?" and "Which fields get saved/restored for persistent objects?"
- questions…?
-
-
- Suppose that there is a metadata table (stored with the application, but only
- loaded into memory when needed) which contains the name, offset, and type of
- each field for each class.
-
- Add these two methods to TObject:
- -----------------------------------------------------------------------------
- PROCEDURE TObject.ClassFields(debugging: BOOLEAN;
- theClass: ObjClassID;
- DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: INTEGER));
- VAR itsName: Str255;
- itsAddr: Ptr;
- itsType: INTEGER;
-
- BEGIN
-
- {$IFC qDebug}
- IF debugging THEN
- BEGIN
- GetClassNameFromID(theClass, itsName);
- DoToField(itsName, NIL, bClass);
- {$ENDC}
-
- FOR <each field of theClass, according to metadata table> DO
- BEGIN
- <look up itsName, itsAddr, and itsType>;
- DoToField(itsName, itsAddr, itsType);
- END;
-
- END;
-
-
- PROCEDURE TObject.EachFieldDo(debugging: BOOLEAN;
- DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: INTEGER));
- PROCEDURE DoFields(theClass: ObjClassID);
- BEGIN
- ClassFields(debugging, theClass, DoToField);
- END;
-
- BEGIN
- DoFields(SELF.GetClass);
- ForAllSuperClassesDo(DoFields);
- END;
- -----------------------------------------------------------------------------
-
- Having MacApp use EachFieldDo in its Inspector and Read/Write-persistent-object
- methods would therefore provide the correct default behaviors.
-
-
-
- Now if you want to change the behaviors for a particular class, you override,
- thus:
- -----------------------------------------------------------------------------
- PROCEDURE TMyObject.ClassFields(debugging: BOOLEAN;
- theClass: ObjClassID;
- DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
- BEGIN
- IF theClass = SELF.GetClass THEN
- BEGIN
-
- {$IFC qDebug}
- IF debugging THEN { Header, and non-"persistent" fields… }
- BEGIN
- DoToField('TMyObject', NIL, bClass);
- DoToField('fieldN1', @fieldN1, bTypeN1);
- :
- DoToField('fieldNn', @fieldNn, bTypeNn);
- END;
- {$ENDC}
-
- DoToField('fieldP1', @fieldP1, bTypeP1); { These are my }
- : { "persistent" }
- DoToField('fieldPn', @fieldPn, bTypePn); { fields… }
-
- END
- ELSE
- INHERITED ClassFields(theClass, DoToField);
- END;
- -----------------------------------------------------------------------------
-
- Did I get that right?
-
- -- Dave (too lazy to be on MacApp.Tech$) Goldman, D5295
- Research Software Design
-
-
-
- Guerrilla P.S.:
-
- Although it is obvious that the metadata table of field info should be
- generated by the compiler and linker, that doesn't mean that we couldn't --
- while we're waiting -- generate it ourselves by calling an appropriate
- "registration" routine for each and every field of each and every class at
- application-initialization time. (Of course, this stopgap measure could
- probably make use of existing Fields methods.)
-
-